//
//  IndexPageNewModel.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/3/28.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "IndexPageNewModel.h"
#import "XXTool.h"

@implementation IndexViewCellModel

@end

@implementation IndexPageNewModel

+(void)getIndexNewsWithType:(NSString *)newsType beforeGetData:(void (^)())beforeGet completion:(void (^)(IndexPageNewModel*))block
{
    beforeGet();
    [DKHTTPRequest sendDataWithShortUrl:@"newslist"
                                  Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"newstype=%@&nstart=0&ntotal=10",newsType]]
                             ImageArray:nil
                                TimeOut:10
                             Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                 IndexPageNewModel *temp = [IndexPageNewModel mj_objectWithKeyValues:serverDic];
                                 if (temp.code==200)
                                 {
                                     block(temp);
                                 }
                                 else
                                 {
                                     block(nil);
                                 }
                                 return YES;
                             } IsBuffering:YES
                         IsNeedReplaceWrap:NO
     IsUseUpLoadHead:NO];
}

+(void)getMoreIndexNewsWithType:(NSString *)newsType nowNewsCount:(NSInteger)count completion:(void (^)(IndexPageNewModel *))block
{
    [DKHTTPRequest sendDataWithShortUrl:@"newslist"
                                  Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"newstype=%@&nstart=%ld&ntotal=10",newsType,(long)count]]
                             ImageArray:nil
                                TimeOut:10
                             Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                 IndexPageNewModel *temp = [IndexPageNewModel mj_objectWithKeyValues:serverDic];
                                 if (temp.code==200)
                                 {
                                     block(temp);
                                     
                                 }
                                 else
                                 {
                                     block(nil);
                                 }
                                 return YES;
                             } IsBuffering:YES IsNeedReplaceWrap:NO
     IsUseUpLoadHead:NO];
}

+ (NSDictionary *)mj_objectClassInArray
{
    return @{
             @"list" : @"IndexViewCellModel",
             };
}

@end
